import { ApplicationConfig, importProvidersFrom, isDevMode } from '@angular/core';
import { provideNzIcons } from './icons-provider';
import { provideNzI18n, zh_CN } from 'ng-zorro-antd/i18n';
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { SharedModule } from './shared/shared.module';
import { NgxsRouterPluginModule, RouterStateSerializer } from '@ngxs/router-plugin';
import { CustomRouterStateSerializer } from './store/router/custom-router-state-serializer';
import { NgxsModule } from '@ngxs/store';
import { states } from './store';
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
import { NgxsFormPluginModule } from '@ngxs/form-plugin';

registerLocaleData(zh);


export const appConfig: ApplicationConfig = {
  providers: [
    provideNzIcons(),
    provideNzI18n(zh_CN),
    provideAnimations(),
    provideRouter([...routes]),
    importProvidersFrom(SharedModule),
    importProvidersFrom(NgxsModule.forRoot([...states], {developmentMode: isDevMode()})),
    importProvidersFrom(NgxsStoragePluginModule.forRoot()),
    importProvidersFrom(NgxsFormPluginModule.forRoot()),
    importProvidersFrom(NgxsRouterPluginModule.forRoot()),
    {provide: RouterStateSerializer, useClass: CustomRouterStateSerializer},
  ],
};
